// Piece.cpp
//
// Created By: Jeremy Butler
// Created On: 30-Mar-2011

#include "Piece.h"

#include <boost/algorithm/string.hpp>
using namespace std;

Piece::Piece() : type() , color() {
  return;
}

Piece::Piece(const Color _color, const PieceType _type)
		: color(_color),
		  type(_type) {
  return;
}

Piece::Piece(const Piece & other) : color(other.color),
				    type(other.type) {
  return;
}

Piece::~Piece(){
  return;
}

Piece & Piece::operator = (const Piece & other){
  if(this != &other){
    color = other.color;
    type = other.type;
  }
  return *this;
}

Color Piece::GetColor() const{
  return color;
}

PieceType Piece::GetType() const{
  return type;
}

Color Piece::GetPieceColor(const string & color){
  if(boost::iequals(color,"white"))
    return WHITE;
  else if(boost::iequals(color,"black"))
    return BLACK;
  else
    return NO_COLOR;
}

PieceType Piece::GetPieceType(const string & type){
  if(boost::iequals(type,"pawn"))
    return PAWN;
  else if(boost::iequals(type,"rook"))
    return ROOK;
  else if(boost::iequals(type,"knight"))
    return KNIGHT;
  else if(boost::iequals(type,"bishop"))
    return BISHOP;
  else if(boost::iequals(type,"queen"))
    return QUEEN;
  else if(boost::iequals(type,"king"))
    return KING;
  else
    return NO_TYPE;
}

string Piece::TypetoString(PieceType type){
  if(type == PAWN)
    return "pawn";
  else if(type == ROOK)
    return "rook";
  else if(type == KNIGHT)
    return "knight";
  else if(type == BISHOP)
    return "bishop";
  else if(type == QUEEN)
    return "queen";
  else if(type == KING)
    return "king";
  else
    return "NO_TYPE";
}
